<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">body{padding-top: 0;}</style>
</head>
<body>

<div class="container">
    <form action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="id" name="pid" value="">
        <table class="table table-striped table-condensed">
            <tbody>
            <tr>
                <th>预览</th>
                <td class="col-xs-6 col-sm-4">
                    <img src="" class="img-thumbnail"></a>
                </td>
            </tr>
            <tr>
                <th>上传本地图片</th>
                <td>
                    <input type="file" id="image" name="pic" />
                </td>
            </tr>
            <tr><th></th><td class="text-right"><button type="submit" class="btn btn-primary">保存图片</button></td></tr>
            </tbody>
        </table>
    </form>
</div>

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/url.min.js"></script>
<script src="js/common.js"></script>
<script language="JavaScript">
    var id = $.url('?id');
    var img = $.url('?img');
    var frm = $.url('?from');
    console.info(frm);
    $(function(){
        if(id != null && id >0){
            $("#id").val(id);
        }
        if(img != "null" && img != null && img != ""){
            $(".img-thumbnail").attr("src",api_cfg.file_domain+decodeURI(img));
        }
        $("form").attr("action",api_cfg.domain+"promotion_image?tag=file_upload");
    })
    $("#image").on("change",function(){
        var r = new FileReader();
        f = $(this).get(0).files[0];
        r.readAsDataURL(f);
        r.onload = function (e) {
            $(".img-thumbnail").attr("src",this.result);
        };
    });
</script>
</body>
</html>
